package com.liuhouse.controller;

import com.liuhouse.annotation.mySystemlog;
import com.liuhouse.service.IArticleService;
import com.liuhouse.utils.ResponseResult;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/article")
@Api(tags = "文章相关接口信息" , description = "文章接口描述")
public class ArticleController {

    @Resource
    private IArticleService articleService;

    @GetMapping("/hotArticleList")
    @mySystemlog(xxbusinessName = "获取热门文章信息")
    //ResponseResult 是liuhouse-framework工程里面的utils包下面的类
    public ResponseResult hotArticleList(){
        //查询热门文章,封装成ResponseResult对象返回
       ResponseResult result = articleService.hotArticleList();
       return result;
    }


    @GetMapping("/articleList")
    //ResponseResult是 liuhouse-framework工程里面的utils包下面的类
    public ResponseResult articleList(Integer pageNum , Integer pageSize , Long categoryId){
        return articleService.articleList(pageNum , pageSize , categoryId);
    }


    @GetMapping("/{id}")//路径参数形式的HTTP请求,注意下面的那行只有加@PathVariable注解才能接收路径参数形式的HTTP请求
    public ResponseResult getArticleDetail(@PathVariable("id") Long id){
        return articleService.getArticleDetail(id);
    }


    @PutMapping("/updateViewCount/{id}")
    public ResponseResult updateViewCount(@PathVariable("id") Long id){
        return articleService.updateViewCount(id);
    }


}
